#include <LitStdAfx.h>
#include "LitCoreComponent.h"

Lit::CoreComponent::CoreComponent(Lit::CoreComponent::Type type):mType(type){}
Lit::CoreComponent::~CoreComponent(){}
Lit::CoreComponentList Lit::CoreComponentList::ALL = Lit::CoreComponentList()
						<< Lit::COM_GAMESTATEMANAGER
						<< Lit::COM_SCENEMANAGER
						<< Lit::COM_PHYSICSMANAGER;
Lit::CoreComponentList Lit::CoreComponentList::NONE = Lit::CoreComponentList();

Lit::CoreComponent::Type Lit::CoreComponent::type() const{ return mType; }

void Lit::CoreComponent::initialise( OgreRenderWindowPtr win, OgreCameraPtr cam, OgreSceneManagerPtr mgr ){}
bool Lit::CoreComponent::renderOneFrame( float dt ){ return true; }
void Lit::CoreComponent::shutdown(){}

Lit::CoreComponentList::CoreComponentList(){}
Lit::CoreComponentList::CoreComponentList( Lit::CoreComponentList::Type type ){
	add( type );
}
Lit::CoreComponentList::CoreComponentList(const Lit::CoreComponentList::vec_t& types) : mTypes(types){}
Lit::CoreComponentList::CoreComponentList(const Lit::CoreComponentList& list) : mTypes(list.mTypes){}
Lit::CoreComponentList::~CoreComponentList(){}

bool Lit::CoreComponentList::has( Lit::CoreComponent::Type component ) const
{
	for( auto i=mTypes.begin(); i!=mTypes.end(); i++ )
		if( (*i) == component ) return true;
	return false;
}

void Lit::CoreComponentList::add( Lit::CoreComponent::Type comp ){ 
	if( !has(comp) ) mTypes.push_back( comp );
}
void Lit::CoreComponentList::remove( CoreComponent::Type comp ){ 
	if( !has(comp) ) return;
	for( auto i=mTypes.begin(); i!=mTypes.end(); i++ )
		if( (*i) == comp )
		{
			mTypes.erase( i );
			return;
		}
}
bool Lit::CoreComponentList::operator[]( Lit::CoreComponent::Type component ) const
{
	for( auto i=mTypes.begin(); i!=mTypes.end(); i++ )
		if( (*i) == component )
			return true;
	return false;
}
Lit::CoreComponentList& Lit::CoreComponentList::operator << ( Lit::CoreComponent::Type type )
{
	add( type );
	return *this;
}

Lit::CoreComponentList::vec_t&  Lit::CoreComponentList::types(){
	return mTypes;
}
const Lit::CoreComponentList::vec_t&  Lit::CoreComponentList::types() const{
	return mTypes;
}
void Lit::CoreComponentList::reset(){ mTypes.clear(); }